<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>mymsgro</title>
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<link rel="stylesheet" type="text/css" href="css/meniu.css" />
	<link rel="stylesheet" type="text/css" href="css/style.css" />

</h:head>

<h:body>

	<ui:include src="header.xhtml" />

	<h:panelGroup layout="block" id="content">

		<ui:include src="leftMenu.xhtml" />

		<h:panelGroup layout="block" id="contenRight">
<f:event type="preRenderView" listener="#{candidateBean.preRenderView}"/>
			<h:panelGroup layout="block" id="header" style="margin-top: 20px;">
				<ul>
					<li id="selected"><a>List of candidates</a></li>
				</ul>
			</h:panelGroup>

			<h:panelGroup layout="block" id="contentTab">

				<h:form>


					<h:commandButton value="View - List of interviews"
						action="listOfInterviews.xhtml" styleClass="butoaneDomain2">
					</h:commandButton>
				</h:form>

				<h:outputText value="#{candidateBean.errorMessDelete}"
					style="color:red" />

				<h:form>


					<h:panelGroup rendered="#{candidateBean.deletion == true}"
						layout="block">
						<h:outputText value="Confirm deletion" style="color:red">
						</h:outputText>
						<h:commandButton value="Yes"
							action="#{candidateBean.deleteCandidate}"></h:commandButton>
						<h:commandButton value="No" action="#{candidateBean.init}"></h:commandButton>
					</h:panelGroup>


					<p:dataTable id="dt" value="#{candidateBean.candidates}"
						 var="candidate"
						paginator="true" rows="10"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15">

						<p:column width="100">
							<f:facet name="header">

								<h:outputText value="View CV" />

							</f:facet>

							<h:commandButton style="width: 17px;"
								image="resources/img/view.png" action="#{candidateBean.viewCv}">

								<f:param name="candidateId" value="#{candidate.id}"></f:param>

							</h:commandButton>



						</p:column>

						<!--  	<p:column>
							<f:facet name="header">
								<h:outputText value="FirstName" />
							</f:facet>
							<h:inputText value="#{candidate.firstname}" />
						</p:column> -->

						<p:column width="100" filterBy="#{candidate.lastname}">
							<f:facet name="header">
								<h:outputText value="LastName" />
							</f:facet>
							<h:inputText value="#{candidate.lastname}" />
						</p:column>

						<p:column width="100">
							<f:facet name="header">
								<h:outputText value="Email" />
							</f:facet>
							<h:inputText value="#{candidate.email}" />
						</p:column>

						<p:column width="100" filterBy="#{candidate.statut}">
							<f:facet name="header">
								<h:outputText value="Statut" />
							</f:facet>

							<h:outputText value="#{candidate.statut}" />

						</p:column>

						<p:column width="100">
							<f:facet name="header">
								<h:outputText value="Delete" />
							</f:facet>
							<h:commandButton value="X"
								action="#{candidateBean.delete(candidate.id)}"
								disabled="#{candidate.statut != 'rejected'}" />
						</p:column>
						<p:column width="100">
							<f:facet name="header">
								<h:outputText value="Appointment" />
							</f:facet>

							<h:commandButton value="Appointment"
								action="#{candidateBean.getCandidateForInterview}"
								disabled="#{candidate.statut != 'waiting'}">
								<f:param name="id" value="#{candidate.id}" />
							</h:commandButton>

						</p:column>

						<p:column width="100">
							<f:facet name="header">
								<h:outputText value="Employ" />
							</f:facet>

							<h:commandButton value="Employ" styleClass="buttonCandidate"
								action="#{employeeBean.addEmployeePage}"
								disabled="#{candidate.statut != 'waiting'}">
								<f:param name="id" value="#{candidate.id}" />
								<f:param name="firstname" value="#{candidate.firstname}" />
								<f:param name="lastname" value="#{candidate.lastname}" />
							</h:commandButton>

						</p:column>

						<p:column width="100">
							<f:facet name="header">
								<h:outputText value="Reject" />
							</f:facet>

							<h:commandButton value="Reject" styleClass="buttonCandidate"
								action="#{candidateBean.rejectCandidate}"
								disabled="#{candidate.statut != 'waiting'}">
								<f:param name="id" value="#{candidate.id}" />
							</h:commandButton>


						</p:column>

					</p:dataTable>

					<h:commandButton id="submit" value="Update" styleClass="butoaneDomain2"
						actionListener="#{candidateBean.checkValues}">
						<f:ajax execute="@all" render="errorMess"></f:ajax>
					</h:commandButton>


					<h:outputText id="errorMess" value="#{candidateBean.errorMess}"></h:outputText>

				</h:form>

			</h:panelGroup>
		</h:panelGroup>
	</h:panelGroup>

</h:body>
</html>